package com.example.filesystem;

import java.util.ArrayList;

public class Directory extends FileNode {

    private ArrayList<FileNode> subNodes = new ArrayList<>();

    public Directory(String path) {
        super(path);
    }

    @Override
    public Integer calculateNumOfFile() {
        Integer numOfFile = 0;
        for (FileNode node : subNodes) {
            numOfFile += node.calculateNumOfFile();
        }
        return numOfFile;
    }

    @Override
    public Integer calculateSizeOfFile() {
        Integer sizeOfFile = 0;
        for (FileNode node : subNodes) {
            sizeOfFile += node.calculateSizeOfFile();
        }
        return sizeOfFile;
    }

    @Override
    public void addNode(FileNode node) {
        this.subNodes.add(node);
    }

    @Override
    public void removeNode(FileNode node) {
        this.subNodes.remove(node);
    }
}